from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
import time,os

class Base():
    def __init__(self):
        cap = {
            "platformName": "Android",
            "deviceName": "emulator-5554 ",
            "appPackage": "com.xiachufang",
            "appActivity": "com.xiachufang.activity.home.HomeActivity",
            "noReset": True
        }
        os.system('adb root')
        self.driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',cap)
        self.driver.implicitly_wait(25)
        sleep(10)

    def jieping(self,filename):
        t = time.strftime('%Y%m%d%H%M%s',time.localtime())
        self.driver.save_screenshot(t+filename)

    def qingqiao(self,x,y):
        self.driver.tap([(x,y)],500)

    def huadong(self,x,y,x2,y2):
        self.driver.swipe(x,y,x2,y2,500)

    def quit_drive(self):
        self.driver.quit()



